﻿using System;
using System.Collections.Generic;
using System.Text;
using Antu.WebControls;
using System.Web.UI.WebControls;
using System.Web;
using Antu.WorkFlowFactory;
using Antu.Core.Services;
using System.Data;
using EluZSProvider;

namespace WebSys.UI.Control.ZhengShou
{
    public class eHeadControl : MPBasicTemplate
    {
        FlowFactoryProvider _FlowFactoryProvider = (FlowFactoryProvider)ProviderService.ProviderServiceMange.GetProvider("FlowFactoryProvider");
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        protected override void OnLoad(EventArgs e)
        {
            
            base.OnLoad(e);
            Literal showname = (Literal)FindControl("showname");
            Label lbtnShouLi = (Label)FindControl("lbtnShouLi");
            Label showgw = (Label)FindControl("showgw");
            string userid = HttpContext.Current.Session["UserID"].ToString();
            //string caijueke=System.Web.Configuration.WebConfigurationManager.AppSettings["CaiJueKe"].ToString();//获得AppSetting.config中裁决科的值
            //DataTable dt = _FlowFactoryProvider.GetInstanceListByUserId(userid, "");
            //int row = 0;
            //if (dt.Rows.Count > 0)
            //{
            //    row = dt.Rows.Count;//获得待办事项条数
            //}
            if (HttpContext.Current.Session["UserName"] != null && HttpContext.Current.Session["UserName"].ToString() != "" && HttpContext.Current.Session["LoginUserName"] != null)
            {
                showname.Text = HttpContext.Current.Session["LoginUserName"].ToString() + "(" + HttpContext.Current.Session["UserName"].ToString() + ")";
            }
            string isPublishSite = System.Configuration.ConfigurationManager.AppSettings["PublishSite"].ToString();
            if (isPublishSite == "2")
            {
                base.Page.ClientScript.RegisterStartupScript(this.GetType(), "disli1", "<script>disli1()</script>");
            }
            else if (isPublishSite == "1")
            {
                //lbtnShouLi.Visible = true;//显示待办事项的Lable
                //lbtnShouLi.Text = "待办事项（" + row + "）";
                //lbtnShouLi.Attributes.Add("onclick", "showc('../OfficeFlow/Transactbusiness.aspx','案件办理');show2();window.parent.leftFrame.show2('" + _EluZSDataProvider.GetString("select t.order_id from zs_menu t where t.menu_title='流程管理'") + "')");//调用前台的JS

                //lbtnShouLi.Attributes.Add("style", "cursor:pointer; color:#223399");//添加样式
            }

            string sql = "Select * from zs_gw where 1=1 and 接收人员 like '%" + HttpContext.Current.Session["LoginUserName"].ToString() + "%' and 是否已读 = '0' ";
            DataTable dtgw = _EluZSDataProvider.GetTable(sql);
            showgw.Text = "未读公文（" + dtgw.Rows.Count + "）";
            showgw.Attributes.Add("onclick", "showc('../RCManage/RC_FWSelect.aspx','查看公文');show2();window.parent.leftFrame.show2('" + _EluZSDataProvider.GetString("select t.order_id from zs_menu t where t.menu_title='日常办公'") + "')");//调用前台的JS
            if (dtgw.Rows.Count>0)
            {
                showgw.Attributes.Add("style", "cursor:pointer; color:red; font-size:16px;");//添加样式
            }
            else
            {
                showgw.Attributes.Add("style", "cursor:pointer; color:green; font-size:16px;");//添加样式
            }
            
           




            //Button button1 = (Button)FindControl("Button1");
            //button1.Click += new EventHandler(button1_Click);
        }
        //protected void button1_Click(object sender, EventArgs e)
        //{
        //    HttpContext.Current.Session["UserID"] = null;
        //    HttpContext.Current.Session["UserName"] = null;
        //    HttpContext.Current.Session["LoginUserName"] = null;
        //    HttpContext.Current.Response.Write("<script>window.parent.location.href('../login.aspx');</script>");
        //}
    }
}
